using System;
using System.Collections.Generic;

namespace TestCases.Utils.Comparers
{
    public class TypeComparer: IComparer<Type>
    {

        private static readonly TypeComparer _instance = new TypeComparer();

// Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
// ReSharper disable EmptyConstructor
        static TypeComparer()
// ReSharper restore EmptyConstructor
        {
        }

        private TypeComparer()
        {
        }

        public static TypeComparer Instance
        {
            get { return _instance; }
        }        
        
        
        public int Compare(Type x, Type y)
        {
            if (x == y)
            {
                return 0;
            }            

            if (x.IsAssignableFrom(y))
            {
                return -1;
            }

            return 1;
        }


    }
}